<?php
declare (strict_types = 1);

namespace app\admin\controller;

use app\BaseController;
use app\common\lib\Arr;
use app\common\lib\Show;
use think\facade\View;
use app\admin\business\Module;

class Index extends BaseController
{
    public function index()
    {

        return View::fetch();
    }

    public function getModule()
    {
        $module = new Module();
        $res    = $module->getNormalModule('id,pid,name,module,action,icon', ['is_show' => 1]);
        $result = Arr::getModuleTree($res);
        $data = [
            'clearInfo' => [
                'clearUrl' => 'api/clear.json'
            ],
            'homeInfo'  => [
                'title' => '首页 home',
                'icon'  => "fa fa-home",
                "href"  => "/admin/index/welcome"
            ],
            'logoInfo'  => [
                'title' => '电商后台管理',
                'href'  => '',
            ],
            'menuInfo'  => [
                'currency' => $result[0]
            ]
        ];
        return Show::success($data);
    }

    public function welcome()
    {
        return View::fetch();
    }
}
